package com.itheima.demo;

import java.util.Scanner;

public class Demo1 {
    public static void main(String[] args) {
        //1.已知的用户名和密码
        String username = "admin";
        String password = "123";

        for(int i = 1 ; i <= 3;i++){
            //2.键盘录入登录的用户名和密码
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入用户名:");
            String scUsername = sc.nextLine();
            System.out.println("请输入密码:");
            String scPassword = sc.nextLine();
            if(username.equals(scUsername) && password.equals(scPassword)){
                System.out.println("登录成功");
            }else {
                if(i == 3){
                    System.out.println("您的次数已经达到上限");
                }else {
                    System.out.println("登录失败,您还剩下" +(3 - i)+ "次机会");
                }
            }
        }

    }


}
